//
//  DDTabBar.swift
//  SinaWeibo
//
//  Created by mac on 16/1/11.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class DDTabBar: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        addChildViewController(DDHomeController(), title: "首页", imageName:"tabbar_home" )
        addChildViewController(DDMessageController(), title: "消息", imageName:"tabbar_message_center" )
       
         addChildViewController(DDDiscoverController(), title: "发现", imageName:"tabbar_discover" )
         addChildViewController(DDProfileController(), title: "我", imageName:"tabbar_profile" )
          let tabbar = DDBottomBar()
        setValue(tabbar, forKey:"tabBar")
        print(tabBar.classForCoder)
        
       
    }
    
   private func addChildViewController(vc :UIViewController,title : String ,imageName : String) {
        let nav = UINavigationController(rootViewController: vc)
        addChildViewController(nav)
        
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
         let imagename =  imageName + "_highlighted"
//        vc.tabBarItem.selectedImage =  UIImage(named: imagename)?.imageWithRenderingMode(.AlwaysOriginal)
//        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
         vc.tabBarItem.selectedImage =  UIImage(named: imagename)
        tabBar.tintColor = UIColor.orangeColor()
        
        
    }

 
    

}
